// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者，助力中小企业发展 
// +----------------------------------------------------------------------
// | Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
// +----------------------------------------------------------------------
// | 沃德代驾系统并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
// +----------------------------------------------------------------------

const user = {
	namespaced: true,
	state: {
		// 登录鉴权
		token: "",
		// 用户信息
		userInfo: {},
		// 司机信息
		driverInfo: {},
	},
	mutations: {
		// 设置token
		setToken(state, token) {
			state.token = token
		},
		// 设置用户信息
		setUserInfo(state, userInfo) {
			state.userInfo = userInfo
		},
		// 设置司机信息
		setDriverInfo(state, driverInfo) {
			state.driverInfo = driverInfo
		},
		// 清除登录信息
		clearAuth(state) {
			state.token = ""
			state.userInfo = {}
			state.driverInfo = {}
			uni.removeStorageSync("token")
			uni.removeStorageSync("userInfo")
			uni.removeStorageSync("driverInfo")
			this.commit('app/setDriverSocket', 2)
		},
	},
}

export default user